// 获取全局应用程序实例对象
// const app = getApp();

// 创建页面实例对象
Page({
	// 页面的初始数据
	data: {
		title: 'main',

		filter:{
			show: false,
			clasName: 'hidden'
		},
		/**
		 * 筛选项的选中城市
		 * @type {Object}
		 */
		choosedCity: {
			id: '',
			name: '大理'
		}
	},

	// 生命周期函数--监听页面加载
	onLoad() {
		// TODO: onLoad
	},
	onShow() {
		this.hideCitySwitch();
	},
	// 页面分享设置
	onShareAppMessage() {
		return {
			title: 'share title',
			path: 'pages/main/main',
		};
	},

	showFilter(){
		this.setData({
			'filter.show': !this.data.filter.show,
			'filter.clasName': !this.data.filter.show?'shown':'hidden'
		});
	},

	/**
	 * 跳转到选择城市页面
	 * @Author   Warrenyang
	 * @DateTime 2018-01-08
	 */
	gotoCity(){
		wx.navigateTo({
		  url: '/pages/city-switch/city-switch'
		})
	},
	/**
	 * 隐藏选择城市页面
	 * @Author   Warrenyang
	 * @DateTime 2018-01-08
	 */
	hideCitySwitch(){
		/**
		 * 获取选中并存到了Storage里面的城市name和id
		 */
		var city_name = wx.getStorageSync('city_name');
    var city_id = wx.getStorageSync('city_id');
    console.log(city_name, city_id);
    if(city_name){
    	this.setData({
    		choosedCity: {
    			name: city_name,
    			id: city_id
    		}
    	})
    }
	}
});
